home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
room3d
/
fdrivers.frm
< prev
next >
Wrap
Text File
|
1999-02-23
|
9KB
|
293 lines
VERSION 5.00
Begin VB.Form fDrivers
AutoRedraw = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
ClientHeight = 4500
ClientLeft = 0
ClientTop = 0
ClientWidth = 6000
LinkTopic = "Form1"
Moveable = 0 'False
Picture = "fDrivers.frx":0000
ScaleHeight = 300
ScaleMode = 3 'Pixel
ScaleWidth = 400
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.ListBox lstDrv
BackColor = &H80000006&
ForeColor = &H0000FF00&
Height = 2595
Left = 240
TabIndex = 5
Top = 840
Width = 5535
End
Begin VB.Label lblCancel
BackStyle = 0 'Transparent
Height = 495
Left = 240
TabIndex = 4
Top = 3720
Width = 2655
End
Begin VB.Label lblAccept
BackStyle = 0 'Transparent
Height = 495
Left = 3120
TabIndex = 3
Top = 3720
Width = 2655
End
Begin VB.Shape shpBorder
BorderColor = &H00808080&
Height = 495
Index = 2
Left = 3120
Top = 3720
Width = 2655
End
Begin VB.Shape shpBorder
BorderColor = &H00808080&
Height = 495
Index = 3
Left = 240
Top = 3720
Width = 2655
End
Begin VB.Shape shpBorder
BorderColor = &H00808080&
Height = 495
Index = 1
Left = 240
Top = 240
Width = 5535
End
Begin VB.Label lblTitle
Appearance = 0 'Flat
BackColor = &H80000005&
BackStyle = 0 'Transparent
Caption = "Select Direct3D driver"
BeginProperty Font
Name = "Arial"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C0C0C0&
Height = 240
Index = 10
Left = 360
TabIndex = 2
Top = 360
Width = 5280
End
Begin VB.Label lblCaptionAccept
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Accept"
BeginProperty Font
Name = "Arial"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C0C0C0&
Height = 255
Left = 3120
TabIndex = 1
Top = 3840
Width = 2655
End
Begin VB.Label lblCaptionCancel
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "Cancel"
BeginProperty Font
Name = "Arial"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C0C0C0&
Height = 255
Left = 240
TabIndex = 0
Top = 3840
Width = 2655
End
End
Attribute VB_Name = "fDrivers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' Color constants for display of selection ...
Private Const RGBHighLight = 12640480 ' Highlight for mouse hover
Private Const RGBStandard = 12632256 ' Default gray
Private Const RGBSelected = 12648447 ' Highlight for selected items
' Enumeration for possible highlights
Private Enum eHighlights
eHighlightNone = -1
eHighlightDriver = 0
eHighlightAccept = 2
eHighlightCancel = 1
End Enum
' DirectX instance variables...
Private I_oDDInstance As IDirectDraw2 ' Instance of DirectDraw interface
Private I_oD3DInstance As IDirect3D2 ' Instance of Direct3DIM interface
' Local copies of form properties...
Private I_bStatus As Boolean ' Contains error status
' STATUS: Tells if driver detection succeeded
Public Property Get Status() As Boolean
Status = I_bStatus
End Property
' FORMLOAD: Query Direct3D for drivers, set labels
Private Sub Form_Load()
' Setup local variables ...
Dim L_nRun As Integer
' Detect drivers ...
' Create instance of DirectDraw
DirectDrawCreate ByVal 0&, I_oDDInstance, Nothing
' Check instance existance, terminate if missing
If I_oDDInstance Is Nothing Then
I_bStatus = False
Me.Hide
Exit Sub
End If
' Query DirectDraw for D3D interface
Set I_oD3DInstance = I_oDDInstance
' Check instance existance, terminate if missing
If I_oDDInstance Is Nothing Then
I_bStatus = False
Me.Hide
Exit Sub
End If
' Set error handler to local for enumeration only
On Error Resume Next
' Start the callback that does the driver enumeration
G_nD3DDriverCount = -1
I_oD3DInstance.EnumDevices AddressOf EnumDeviceCallback, 0
' Catch any error resulting from the enumeration and terminate
If err.Number > 0 Then
I_bStatus = False
Me.Hide
Exit Sub
End If
' Reset error handler to default
On Error GoTo 0
' Check if any drivers found
If G_nD3DDriverCount = -1 Then
I_bStatus = False
Me.Hide
Exit Sub
End If
' Remember selected driver, initially the first one
G_dD3DSelectedDriver = G_dD3DDriver(0)
I_bStatus = True
' Cleanup DirectX
Set I_oD3DInstance = Nothing
Set I_oDDInstance = Nothing
' Write drivers into labels ...
For L_nRun = 0 To 9
If L_nRun <= G_nD3DDriverCount Then
lstDrv.AddItem G_dD3DDriver(L_nRun).DESC
End If
Next
If lstDrv.ListCount > 0 Then lstDrv.ListIndex = (lstDrv.ListCount - 1)
If lstDrv.ListCount > 1 Then lstDrv.ListIndex = (lstDrv.ListCount - 2)
End Sub
' LBLACCEPT_CLICK: Accept selected driver and close dialog
Private Sub lblAccept_Click()
lstDrv.SetFocus
G_dD3DSelectedDriver = G_dD3DDriver(lstDrv.ListIndex)
' Show click on label
Me.lblAccept.ForeColor = RGBSelected
' Close form
Me.Hide
Call AppStart
End Sub
' LBLCANCEL_CLICL: Close form and return cancelled
Private Sub lblCancel_Click()
' Show click on label
Me.lblCancel.ForeColor = RGBSelected
' Set cancel status
I_bStatus = False
' Close form
Me.Hide
End
End Sub
Private Sub lblTitle_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Call SetHighlights(eHighlightNone)
End Sub
Private Sub lblCancel_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call SetHighlights(eHighlightCancel